var teamList = {
	init:function(){
        this.layuiUse();	
        this.teamList();
	},
	layuiUse:function(){
		layui.use(['layer', 'form','jquery'], function(){
            var layer = layui.layer,
                form = layui.form,
                $ = layui.$;
            if(window.location.href.indexOf('teamType=1')!=-1){
                $('.teamType').html('一级');
            }else if(window.location.href.indexOf('teamType=2')!=-1){
                $('.teamType').html('二级');
            }else if(window.location.href.indexOf('teamType=3')!=-1){
                $('.teamType').html('三级');
            }
        });
    },
    //团队列表
    teamList:function(){
        layui.use(['flow'], function(){
            var flow = layui.flow;
            //分页
            flow.load({
                elem: '#teamList', 
                done: function(page, next){
                var lis = [];
                $.ajax({
                    type: 'post',
                    url:link+'/mobile/user/invitation/list',
                    data:{
                        token:GetCookie('token'),
                        level:window.location.href.split('teamType=')[1],
                        pageNum:page,
                    },
                    dataType: 'json',
                    success: function (res) {
                        if(res.code=='10000'){ 
                            if(res.entity.list.length>0){
                                layui.each(res.entity.list, function(index, item){
                                    if(item.createDate){
                                        createDate = item.createDate.split(' ')[0];
                                    }else{
                                        createDate = '';
                                    }
                                    lis.push('<li class="layui-col-xs12 layui-row boxShadoweee mt10 radius10 p10 pl20 pr20">'+
                                                '<div class="layui-col-xs2">'+
                                                    '<img src="../../images/person/normalPerson.png" alt="" class="w100">'+
                                                '</div>'+
                                                '<div class="layui-col-xs10 layui-row pl15">'+
                                                    '<span class="layui-col-xs9 layui-row">'+
                                                        '<p class="layui-col-xs12 color333 h30 line30">'+item.nickname+'：'+item.mobile+'</p>'+
                                                        '<p class="layui-col-xs12 color999 font12 h20 line20">注册时间：'+createDate+'</p>'+
                                                    '</span>'+
                                                    '<span class="layui-col-xs3">'+
                                                        '<p class="layui-col-xs12 color333 font12 h30 line30">消费总金额</p>'+
                                                        '<p class="layui-col-xs12 color666">￥<span class="colorRed font20 bold">'+item.totalExpenses+'</span></p>'+
                                                    '</span>'+
                                                '</div>'+
                                            '</li>');
                                });
                                next(lis.join(''), page < Math.ceil(res.entity.total/10));
                                $('.layui-flow-more').addClass('layui-col-xs12');
                            }else{
                                $('.teamList').html('<p class="colorSystem alignC mt30">暂时没有团队列表哦~</p>');
                            }
                        }else{
                            $('.teamList').html('<p class="colorSystem alignC mt30">系统繁忙，请稍后再试~</p>');
                        }
                    },
                    error:function(res){
                        
                    },
                });
                }
            });
        });
    },
};
teamList.init();

          